﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Graphics;
using Boom.Navigation;

namespace Boom.GameObjects
{
    public class SkillBoss:ListBoom
    {
        private List<Vector2> _Position_Random;
        private TimeSpan _ElapsedTimeSkill = TimeSpan.Zero;
        private Random _Rand;
        private int _TimeSkill;
        private int _CountSkill;

        public SkillBoss(Game Mygame, ref Texture2D TextureSkill, ref Texture2D TextureFire, bool CheckObs)
            : base(Mygame, ref TextureSkill, ref TextureFire, null, null, 4)
        {
            _Position_Random = new List<Vector2>();
            _Rand = new Random(this.GetHashCode());
            _CountSkill = Config.CountSkill;
            _TimeSkill = Config.TimeSkill;
        }

        //Đặt boom ngẫu nhiên theo danh sách được chọn ngẫu nhiên
        protected void Skill_Boss()
        {
            Random_Position(_CountSkill);
            for (int i = 0; i < _Position_Random.Count; i++)
            {
                Position = _Position_Random[i];
                CheckNewBoom();
            }
        }

        //Tạo ngẫu nhiên một danh sách tọa độ trên màn hình
        private void Random_Position(int Count)
        {
            _Position_Random.Clear();
            for (int i = 0; i < Count; i++)
            {
                int temp = _Rand.Next(225);
                _Position_Random.Add(new Vector2(temp / 15 * 40, temp % 15 * 40));
            }
        }

        private void UpdateSkill(GameTime gameTime)
        {
            _ElapsedTimeSkill += gameTime.ElapsedGameTime;
            if (_ElapsedTimeSkill > TimeSpan.FromSeconds(_TimeSkill))
            {
                _ElapsedTimeSkill -= TimeSpan.FromSeconds(_TimeSkill);
                _CountSkill++;
                _Lenght++;
                Skill_Boss();
            }
        }

        public override void Update(GameTime gameTime)
        {
            UpdateSkill(gameTime);
            base.Update(gameTime);
        }
    }
}
